package com.example.yywebflux01;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class StockController {

    private final StockPriceService stockPriceService;

    public StockController(StockPriceService stockPriceService) {
        this.stockPriceService = stockPriceService;
    }

    @GetMapping("/stocks/{symbol}")
    public Flux<StockPrice> streamStockPrices(@PathVariable String symbol) {
        return stockPriceService.getStockPrices(symbol);
    }
}
